package com.cjl.jdk8;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class StringComparator {
    public static void main(String[] args) {
        List<String> names = Arrays.asList("lisi","zhangsan","cjl","hy");


//        Collections.sort(names, new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o2.compareTo(o1);
//            }
//        });


        Collections.sort(names,(o1,o2)-> o2.compareTo(o1));
        Collections.sort(names,(o1,o2)-> {return o2.compareTo(o1);});


        Collections.sort(names,Comparator.naturalOrder());

        Collections.sort(names,Comparator.reverseOrder());


        System.out.println("StringComparator.main "+names);

    }
}
